<template>
	<view class="content">
		<view class="section-1">
			<view class="section-body">
				<view class="project-name">
					<text class="iconfont icon-xiangmu"></text>项目：{{name}}
				</view>
				<!-- <view class="total">
					<view class="item" v-for="item in board" :key="item.name">
						<view class="shape" v-if="item.right"></view>
						<view class="shape2" v-if="item.bottom"></view>
						<view class="top">{{item.name}}</view>
						<view class="bottom">{{item.count}}</view>
					</view>
				</view> -->
			</view>
		</view>
		<view class="section-0">
			<view class="section-body">
				<!-- <view class="form">
					<view class="form-item">
						<view class="label">项目名称</view>
						<view class="shape"></view>
						<view class="input">
							<u--input placeholderClass="input-placeholder" class="input-body" placeholder="项目名称"
								v-model="form.project_name"></u--input>
						</view>
					</view>
					<view class="actions">
						<view class="action" @click="handleResetForm()">
							<text>重</text>
							<text>置</text>
						</view>
						<view class="action search" @click="handleSearch()">
							<text>查</text>
							<text>询</text>
						</view>
					</view>
				</view> -->
				<view class="top-tab">
					<view :class="`item ${curTab.id === item.id ? 'item__active' : ''}`" @click="setCurTab(item)"
						v-for="item in tabList" :key="item.id">
						{{item.name}}
						<view class="shape"></view>
					</view>
				</view>
				<view class="problem-list-container">
					<problemList v-if="Object.keys(curTab).length > 0" :fixed="false" :id="id" :type="curTab.dict_label" 	:check_type = check_type></problemList>
				</view>
				<!-- <view class="list">
					<view class="item" v-for="item in list" :key="item.id">
						<view class="title">{{item.check_content}}</view>
						<view class="desc">
							<view class="desc-item">
								<view class="left">违章库</view>
								<view class="right">{{item.peccancy_content}}</view>
							</view>
							<view class="desc-item">
								<view class="left">责任人</view>
								<view class="right">{{item.zrr_name}}</view>
							</view>
							<view class="desc-item">
								<view class="left">问题图片</view>
								<view class="right">
									<view class="image-wrapper">
										<image v-if="item.check_path" :src="data.check_path" mode="aspectFill"></image>
									</view>
								</view>
							</view>
							<view class="desc-item">
								<view class="left">整改图片</view>
								<view class="right">
									<view class="image-wrapper">
										
									</view>
								</view>
							</view>
						</view>
					</view>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	import problemList from '@/components/problem_list/index.vue';
	import { checkInfoApi, checkProblemApi } from '@/api/statistics.js';
	import { getProject } from '@/api/patrol.js';
	export default {
		components: {problemList},
		data() {
			return {
				id: '',
				name: '',
				check_type:2,
				form: {
					project_name: ''
				},
				board: [
					{ name: '安全问题总数', count: 0, right: true, bottom: false, type: 'risk_num' },
					{ name: '未整改问题总数', count: 0, right: false,  bottom: false, type: 'risk_num_2' },
				],
				list: [],
				expandList: [],
				curTab: {
					id: 1,
					name: '业主检查',
					dict_label:'业主检查'
				},
				tabList: [
					{
						name: '二级巡查',
						id: 3
					},
					{
						name: '省公司督察',
						id: 2
					},		
					{
						name: '业主检查',
						id: 1
					},
					{
						name: '监理检查',
						id: 4
					},
					{
						name: '施工巡查',
						id: 5
					},
				],
			}
		},
		methods: {
			setCurTab(item) {
				this.curTab = item;
				console.log(item)
				this.curTab.dict_label = item.name;
				this.fetchData();
			},
			handleResetForm(){
				for (let key in this.form) {
					this.form[key] = '';
				}
				this.fetchData();
			},
			handleSearch(){
				this.fetchData();
			},
			expandChange(id) {
				const idx = this.expandList.indexOf(id);
				if (idx !== -1) {
					this.expandList.splice(idx, 1);
				} else {
					this.expandList.push(id);
				}
			},
			async fetchInfo() {
				uni.showLoading({title: '加载中...'});
				const { data } = await checkProblemApi({
						id: this.id,
					});
				uni.hideLoading();
				if (data.code === 1) {
					this.board[0].count = data.data.tongJi.total;
					this.board[1].count = data.data.tongJi.unchanged_total;
					// this.tabList = data.data.list;
					this.curTab = this.tabList[2];
				} 
			},
			async fetchData() {
				uni.showLoading({title: '加载中...'});
				const { data } = await getProject({
					project_id: this.id,
					check_source: this.curTab.dict_label,
					check_type: 2,
					state: '2'
				});
				uni.hideLoading();
				if (data.code === 1) {
					this.list = data.data.data;
				} 
			}
		},
		async onReady() {
			await this.fetchInfo();
			// this.fetchData();
		},
		onLoad(data) {
			this.id = JSON.parse(data.params).id;
			this.name = JSON.parse(data.params).project_name;
			
		}
	}
</script>

<style lang="scss" scoped>
	.problem-list-container{
		width: 100%;
	}
	.section-1{
		width: 100%;
		background-color: #2e5efe;
		.section-body{
			width: 100%;
			padding-left: 40rpx;
			padding-right: 40rpx;
			padding-bottom: 50rpx;
			background-color: #1534ce;
			background-size: cover;
			background-repeat: no-repeat;
			border-top-left-radius: 50rpx;
			border-top-right-radius: 50rpx;
			overflow: hidden;
			box-sizing: border-box;
			.total{
				width: 100%;
				@include clear();
				.item{
						width: 50%;
						float: left;
						display: flex;
						flex-wrap: wrap;
						align-content: space-between;
						height: 100rpx;
						position: relative;
						padding-top: 20rpx;
						padding-bottom: 20rpx;
						.shape{
							width: 4rpx;
							height: 84rpx;
							background-image: linear-gradient(rgba(#3658f2, 0.3) 0%, #3658f2 30%, #3658f2 70%, rgba(#3658f2, 0.3) 100%,);
							position: absolute;
							right: 0;
							top: 28rpx;
						}
						.shape2{
							height: 4rpx;
							width: 172rpx;
							background-image: linear-gradient(90deg, rgba(#3658f2, 0.3) 0%, #3658f2 30%, #3658f2 70%, rgba(#3658f2, 0.3) 100%,);
							position: absolute;					
							left: 0;
							right: 0;
							margin: 0 auto;
							bottom: -2rpx;
						}
						.top{
							width: 100%;
							text-align: center;
							font-size: 16rpx;
							font-weight: normal;
							font-stretch: normal;
							letter-spacing: 0rpx;
							color: #95c4fa;
						}
						.bottom{
							width: 100%;
							text-align: center;
							font-size: 58rpx;
							font-weight: bold;
							font-stretch: normal;
							letter-spacing: 0rpx;
							color: #ffde00;
						}
					
				}
			}
			.project-name{
				width: 100%;
				height: 90rpx;
				line-height: 90rpx;
				box-sizing: border-box;
				padding: 0 20rpx;
				background-color: #1534ce;
				background-size: cover;
				background-repeat: no-repeat;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				box-sizing: border-box;
				font-size: 26rpx;
				color: #94c4fa;
				border-bottom: 2rpx solid #3658f2;
				.icon-xiangmu{
					font-size: 26rpx;
					margin-right: 15rpx;
				}
			}
			.item{
				width: 33.33%;
				float: left;
				display: flex;
				flex-wrap: wrap;
				align-content: space-between;
				height: 100rpx;
				position: relative;
				padding-top: 20rpx;
				padding-bottom: 20rpx;
				.shape{
					width: 4rpx;
					height: 84rpx;
					background-image: linear-gradient(rgba(#3658f2, 0.3) 0%, #3658f2 30%, #3658f2 70%, rgba(#3658f2, 0.3) 100%,);
					position: absolute;
					right: 0;
					top: 28rpx;
				}
				.shape2{
					height: 4rpx;
					width: 172rpx;
					background-image: linear-gradient(90deg, rgba(#3658f2, 0.3) 0%, #3658f2 30%, #3658f2 70%, rgba(#3658f2, 0.3) 100%,);
					position: absolute;					
					left: 0;
					right: 0;
					margin: 0 auto;
					bottom: -2rpx;
				}
				.top{
					width: 100%;
					text-align: center;
					font-size: 16rpx;
					font-weight: normal;
					font-stretch: normal;
					letter-spacing: 0rpx;
					color: #95c4fa;
				}
				.bottom{
					width: 100%;
					text-align: center;
					font-size: 58rpx;
					font-weight: bold;
					font-stretch: normal;
					letter-spacing: 0rpx;
					color: #ffde00;
				}
			}
		}
	}
	.section-0 {
		width: 100%;
		background: #2e5efe;
		position: relative;
		top: -50rpx;
		z-index: 10;
		border-top-left-radius: 50rpx;
		background-color: #fff;
		border-top-right-radius: 50rpx;
		.section-body {
			width: 100%;
			height: 100%;
			border-top-left-radius: 50rpx;
			border-top-right-radius: 50rpx;
			background-color: #fff;
			overflow: hidden;
			.top-tab{
				width: 670rpx;
				margin-left: 40rpx;
				height: 80rpx;
				line-height: 80rpx;
				display: flex;
				justify-content: space-between;
				box-sizing: border-box;
				border-top: 2rpx solid #d8e4f2;
				.item{
					font-size: 26rpx;
					font-weight: normal;
					font-stretch: normal;
					line-height: 80rpx;
					letter-spacing: 0rpx;
					color: #9b9b9b;
					position: relative;
					.shape{
						opacity: 0;
						transform: translateY(6rpx);
						position: absolute;
						bottom: 0rpx;
						width: 100%;
						height: 8rpx;
						background-color: #1534ce;
						border-radius: 8rpx;
						transition: 0.3s ease;
					}
				}
				.item__active{
					color: #1534ce;
					.shape{
						opacity: 1;
						transform: translateY(0rpx);
					}
				}
				
			}
			.list{
				width: 670rpx;
				box-sizing: border-box;
				margin-left: 40rpx;
				padding: 0 12rpx;
				padding-top: 20rpx;
				.item{
					width: 100%;
					background-color: #ffffff;
					border-radius: 35rpx;
					box-shadow: 0 0 20rpx 10rpx rgba(#bcbcb5, 0.17);
					margin-bottom: 30rpx;
					.title{
						width: calc(100% - 20rpx);
						margin-left: 10rpx;
						font-size: 26rpx;
						font-weight: normal;
						font-stretch: normal;
						line-height: 30rpx;
						padding-top: 40rpx;
						padding-bottom: 40rpx;
						line-height: 97rpx;
						letter-spacing: 0rpx;
						color: #1534ce;
						border-bottom: 3rpx solid #f2f2f0;
						box-sizing: border-box;
						padding-left: 30rpx;
					}
					.desc{
						width: 100%;
						box-sizing: border-box;
						padding-left: 35rpx;
						padding-right: 65rpx;
						padding-top: 35rpx;
						padding-bottom: 35rpx;
						.desc-item{
							width: 100%;
							@include clear();
							margin-bottom: 18rpx;
							.left{
								width: 120rpx;
								float: left;
								font-size: 26rpx;
								font-weight: normal;
								font-stretch: normal;
								line-height: 30rpx;
								letter-spacing: 0rpx;
								color: #9b9b9b;
							}
							.right{
								width: calc(100% - 120rpx);
								float: left;
								font-size: 26rpx;
								font-weight: normal;
								font-stretch: normal;
								line-height: 30rpx;
								letter-spacing: 0rpx;
								color: #9b9b9b;
								.image-wrapper{
									width: 100%;
									display: flex;
									justify-content: space-between;
									flex-wrap: wrap;
									image{
										width: 200rpx;
										height: 110rpx;
										margin-bottom: 15rpx;
									}
								}
							
							}
						}
					}
				}
			}
			
			.tab{
					width: 100%;
					height: 80rpx;
					@include clear();
					background-color: #1534ce;
					.item{
						width: 33.33%;
						float: left;
						height: 80rpx;
						background-color: #1534ce;
						position: relative;
						.label{
							height: 80rpx;
							line-height: 80rpx;
							position: relative;
							z-index: 10;
							box-sizing: border-box;
							text-align: center;
							width: 100%;
							font-size: 26rpx;
							font-weight: normal;
							font-stretch: normal;
							letter-spacing: 0rpx;
							color: #ffffff;
						}
						.shape{
							z-index: 1;
							width: 50rpx;
							height: 50rpx;
							position: absolute;
							bottom: 0;
							left: -50rpx;
							background: #000;
							display: none;
							background-color: #fff;
							overflow: hidden;
							.shape-body{
								width: 50rpx;
								height: 50rpx;
								background-color: #1534ce;
								border-bottom-right-radius: 40rpx;
							}
						}
						.shape-mirrow{
							z-index: 1;
							left: 0;
							display: none;
							.shape-body{
								border-bottom-right-radius: 0rpx;
								border-bottom-left-radius: 40rpx;
							}
						}
					}
					.item__active{
						border-top-left-radius: 40rpx;
						border-top-right-radius: 40rpx;
						background-color: #fff;
						.label{
							color: #46464a;
						}
						.shape{
							display: block;
						}
						.shape-mirrow{
							display: none;
						}
					}
					.item__active_next{
						border-bottom-right-radius: 50rpx;
						.shape{
							display: none;
						}
						.shape-mirrow{
							display: block;
						}
					}
				
			}

			.actions {
				width: 100%;
				height: 50rpx;
				margin-top: 29rpx;
				padding-bottom: 40rpx;
				display: flex;
				justify-content: space-between;

				.action {
					width: 288rpx;
					height: 48rpx;
					background-color: #395cf5;
					border-radius: 20rpx;
					text-align: center;
					line-height: 48rpx;
					font-size: 26rpx;
					font-weight: normal;
					font-stretch: normal;
					line-height: 48rpx;
					color: #ffffff;

					text {
						&:first-child {
							margin-right: 20rpx;
						}
					}
				}

				.search {
					background-color: #1534ce;
				}
			}

			.form {
				width: 100%;
				padding: 0 75rpx;
				padding-top: 40rpx;
				box-sizing: border-box;

				.form-item {
					width: 600rpx;
					height: 48rpx;
					border-radius: 20rpx;
					border: solid 2rpx #1534ce;
					margin: 0 auto;
					margin-bottom: 25rpx;

					&:last-child {
						margin-bottom: 34rpx;
					}

					@include clear();

					.label {
						float: left;
						width: 134rpx;
						height: 48rpx;
						text-align: center;
						line-height: 44rpx;
						font-size: 26rpx;
						font-weight: normal;
						font-stretch: normal;
						letter-spacing: 0rpx;
						color: #1534ce;
					}

					.shape {
						width: 3rpx;
						height: 32rpx;
						background-color: #7f98ae;
						float: left;
						margin-top: 8rpx;
					}

					.input {
						float: left;
						width: calc(100% - 134rpx - 3rpx);

						.input-body {
							box-sizing: border-box;
							width: 100%;
							height: 44rpx;
							padding: 0 !important;
							border: none;
							padding-left: 30rpx !important;
							padding-right: 30rpx !important;
							font-size: 26rpx;
							font-weight: normal;
							font-stretch: normal;
							letter-spacing: 0rpx;
							color: rgba(0, 0, 0, 0.7);
						}

						.input-placeholder {
							font-size: 26rpx;
							font-weight: normal;
							font-stretch: normal;
							letter-spacing: 0rpx;
							color: rgba(0, 0, 0, 0.5);
						}
					}
				}
			}

		}
	}
</style>
